package com.example.androidgeneric;

import android.content.Context;
import android.util.TypedValue;

public class ValueFormat {

	private static final float DEFAULT_DIP_DENSITY_SCALE = 1.5f;
	
	public static int PXtoDP(Context context, int px) {
		
		float scale = context.getResources().getDisplayMetrics().density;
		
		return (int) (px / DEFAULT_DIP_DENSITY_SCALE * scale);
	}
	
	public static float DPtoPX(Context context, int dp) {
		
		float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, context.getResources().getDisplayMetrics());
		
		return px;
	}
	
}
